﻿@using ECG.Utility
@using ECG.WebUI.CustomHelpers
@using ECG.WebUI.Models
@model IEnumerable<ECG.Common.ProductRateByCateTopListPagingDto>
@{
    ViewBag.Title = "ProductListByTag";
    Layout = "~/Views/Shared/_LayoutHideCate.cshtml";
}

<div class="layout-width">
    <div class="bb_cate_breadcrumb">
        <ul class="ul clearfix">
            <li class="brc">
                <a href="http://localhost:24587" class="bb_cate_bre_first">Trang chủ</a>
            </li>
            <li class="brc">
                <a href="javascript:void(0);" class="bb_cate_bre_first" rel="tag">@ViewBag.TagName</a>
            </li>
        </ul>
        <div class="bcr-line-bottom"></div>
    </div>

    <div class="cate-page-box clearfix">
        <div class="cate-left-box fl">
            <div class="cate-list">
                @*@Html.Action("CategoryMenuLeftAll", "Category")*@
            </div>
        </div>
        <div class="cate-right-box fl">
            <div class="coWrap clearfix">
                <div class="p-tag-info fl">
                    Đang hiện <strong class="itemSizeOnpage"></strong> của <strong>@ViewBag.TotalRecord</strong> kết quả
                </div>
                <div class="fr">
                    <span class="coText2">Sắp xếp</span>
                    @Html.DropDownList("selectSortCategory", new SelectList(CommonHelpers.selectSortCategory(), "Value", "Text", ViewBag.Fillter), new { @Class = "sortDrop" })
                </div>
            </div>
            @if (Model.Any())
            {
                <div class="CoListProduct">
                    <ul class="listp ul clearfix">
                        @foreach (var item in Model)
                        {
                            var pDetailLink = Url.Action("Index", "ProductDetail", new { productId = item.Id, productName = StringUtil.RemoveSpecialCharactersVn(item.Name) });
                            <li>
                                <div class="pItem">
                                    <a href="@pDetailLink" class="pItem-lnkImg">
                                        @if (item.PromotionPrice > 0)
                                        {
                                            <span class="pItem-per">-@item.DiscountPercentage.ToString("#.###")<i>%</i></span>
                                        }
                                        <img src="@item.ImagePath.ImagePathThumb(135, 135)" width="135" height="135" alt="@item.Name">
                                    </a>
                                    <div class="pItem-info">
                                        <div style="line-height: 13px; margin-top: 5px;">
                                            @{
                                        string StarPercent = "0";
                                        if (item.AverageRate > 0)
                                        {
                                            StarPercent = (Convert.ToDouble(item.AverageRate) * 100 / 5).ToString("#.#").Replace(',', '.');
                                        }
                                            }
                                            <span class="itm-ratStars inlineBlocka"><span style="width: @StarPercent%;" class="itm-ratStars itm-ratRating"></span></span>
                                        </div>
                                        <h6>
                                            <a href="@pDetailLink">@item.Name</a>
                                        </h6>
                                        @if (item.PromotionPrice > 0)
                                        {
                                            <p class="pItem-PriceOld">
                                                @item.Price.ToString("##,###,###") đ
                                            </p>
                                            <p class="pItem-PriceNew">
                                                @item.PromotionPrice.ToString("##,###,###") <strong>đ</strong>
                                                <a href="javascript:void(0);" class="fbComment">Bình luận</a>
                                            </p>
                                        }
                                        else
                                        {
                                            <p class="pItem-PriceNew">
                                                @item.Price.ToString("##,###,###") <strong>đ</strong>
                                                <a href="javascript:void(0);" class="fbComment">Bình luận</a>
                                            </p>
                                        }

                                    </div>
                                </div>
                            </li>
                        }
                    </ul>
                    <div class="bb_pagging">
                        @Html.PageLinksOnProductListCatePage((PageInfo)ViewBag.PageInfo, i => Url.Action("ProductListByTag", "ProductTag", new { keyword = ViewBag.Keyword, page = i }))
                    </div>
                </div>   
            }
        </div>
    </div>
</div>
@section scripts
{
    <script>
        $(function () {
            //hien thi so ban ghi dang co tren trang
            LoadItemProductOnpage();
        });
        function LoadItemProductOnpage() {
            var item = $('ul.listp li').size();
            $('.itemSizeOnpage').text(@ViewBag.CurrentPage + ' - ' + item);
        }
    </script>
}